package com.hyy.trigger.action;


import com.hyy.trigger.machine.Basket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.squirrelframework.foundation.fsm.UntypedAnonymousAction;
import org.squirrelframework.foundation.fsm.UntypedStateMachine;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Created by hyygavin on 2018/3/14.
 */
public class BrandAction extends UntypedAnonymousAction {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void execute(Object ruleFrom, Object ruleTo, Object event, Object context, UntypedStateMachine stateMachine) {
        Basket basket = (Basket) context;
        boolean flag = new Random().nextBoolean();
        if (!flag) basket.end();

        Map<String,String> result = new HashMap<>();
        result.put("value",getClass().getName());
        basket.setResultData(result);
        System.out.println(this.getClass().getName() + " : " + Thread.currentThread().getName());
    }

}
